<?php defined('IN_LK') or die('Access Denied');?>
<?php include self::admin_t('header');?>

<ul class="main_nav">
  <li><a href="javascript:void(0);" onmouseover="showcat()" onmouseout="hidecat()" target="_self" id="allcat">所有栏目</a></li>
  <li><a href="?m=admin&c=content_manage" target="_self" class="select">内容管理</a></li>
  <li><a onclick="add_content(<?php echo $catid;?>);" href="javascript:void(0);" target="_self">添加内容</a></li>
  <li><a href="?m=admin&c=content_manage&a=recycler" target="_self">回收站</a></li>
</ul>
<div class="c"></div>
<div class="message msg" id="login_error"><span class="green"><?php echo $catinfo['catname'];?> &raquo; 文档列表</span></div>
<div class="table-list">
<form action="?m=admin&c=content_manage&a=listorder" method="post">
  <table width="100%" cellspacing="0">
    <thead>
      <tr>
        <th width="20"><input type="checkbox" id="listid" onclick="select_all(this.id, 'id[]')" /></th>
        <th width="50">排序</th>
        <th width="60">ID</th>
        <th>标题</th>
        <th align="left" width="60">点击量</th>
        <th align="left" width="80">发布人</th>
        <th width="140">更新时间</th>
        <th width="30">访问</th>
        <th width="140">操作</th>
      </tr>
    </thead>
    <tbody>
      <?php if(is_array($content)){foreach($content as $c){?>
      <tr>
        <td align="center"><input type="checkbox" name="id[]" value="<?php echo $c['id'];?>" /></td>
        <td align="center"><input type="text" class="input input_short input_short_center" name="listorder[<?php echo $c['id']?>]" size="3" value="<?php echo $c['listorder']?>"  /></td>
        <td align="center"><?php echo $c['id'];?></td>
        <td><a href="javascript:void(0);" onclick="edit(<?php echo $c['id'];?>)"><?php echo $c['title'];?></a>
          <?php if($c['thumb']){echo '<span style="color:red">[图]</span>';}echo $c['posids'];?></td>
        <td><?php echo $c['hits'];?></td>
        <td><?php echo $c['username'];?></td>
        <td align="center"><?php echo date('Y-m-d H:i:s', $c['updatetime']);?></td>
        <td align="center"><a target="_blank" href="?m=index&c=show&id=<?php echo $c['id'];?>">访问</a></td>
        <td align="center"><a href="javascript:void(0);" onclick="edit(<?php echo $c['id'];?>)">修改</a> | <?php if($c['allow_comment']){?><a href="?m=index&c=show&id=<?php echo $c['id'];?>#new_comment" target="_blank">查看评论</a><?php }else{?><span>查看评论</span><?php }?> | <a href="javascript:void(0);" onclick="dis(<?php echo $c['id'];?>)">禁用</a></td>
      </tr>
      <?php }}?>
    </tbody>
  </table>
  <div class="bot"> <a href="javascript:void(0);" onclick="select_all('all', 'id[]')">全选</a> / <a href="javascript:void(0);" onclick="select_all('none', 'id[]')">取消</a>
    <input type="submit" value="排序" id="dosubmit" name="dosubmit" class="btn">
    <input type="button" value="删除选中" id="dodelete" name="dodelete" onclick="delete_check('id[]')" class="btn">
  </div>
  </form>
</div>
<?php echo $page_nav;?>
<div id="showmenu"></div>
<?php include self::admin_t('footer');?>
<script type="text/javascript">
function showcat(){var btn = $('#allcat'),o= btn.offset(),menu= $('#showmenu');var links = '<?php foreach($cats as $c){ echo '<a href="?m=admin&c=content_manage&catid=' . $c['catid'] . '" onclick="$(this).hide(\\\'fast\\\')">' . $c['catname'] . '</a>';}?>';menu.css({'top': o.top + 4 + 'px', 'left': o.left + 2 + 'px'}).html('<dl><dd>' + links + '</dd><dl>').show();}
function hidecat(){var menu  = $('#showmenu');menu.hover(function(){menu.show()}, function(){menu.hide()});}
function add_content(id)
{
	var url = "?m=admin&c=content_manage&a=add_content&catid=" + id;
	window.top.art.dialog(
	{
		title : '添加内容',
		iframe: url,
		width : 850,
		height: 500,
		id    : 'add_content'
	},
	function ()
	{
		var d    = window.top.art.dialog({id:'add_content'}).data.iframe;
		var form = d.document.getElementById('dosubmit');
		form.click();
		return false;
	},
	function ()
	{
		window.top.art.dialog({id:'add_content'}).close();
	});
}
function edit(id)
{
	var url = "?m=admin&c=content_manage&a=edit&id=" + id;
	window.top.art.dialog(
	{
		title : '编辑信息',
		iframe: url,
		width : 850,
		height: 500,
		id    : 'edit_content'
	},
	function ()
	{
		var d    = window.top.art.dialog({id:'edit_content'}).data.iframe;
		var form = d.document.getElementById('dosubmit');
		form.click();
		return false;
	},
	function ()
	{
		window.top.art.dialog({id:'edit_content'}).close();
	});
}
function dis(sid)
{
	window.top.art.dialog({
		title: '你确定禁用吗？',
		content:'你确定禁用ID（' + sid + '）吗？<br />恢复请到回收站',	
		width:200,
		height:60,
		id:'dis'
	},
	function()
	{
		$.ajax({
			type: "POST",
			url: "?m=admin&c=content_manage&a=disable",
			data: "id=" + sid,
			success: function(data){
				parent.main.location.reload();
			}
		});
	},
	function()
	{
		window.top.art.dialog({id:'dis'}).close();
	});
}
function delete_check(name)
{
	var ids = '';
	$('input[name="' + name + '"]').each(function()
	{
		if(this.checked)
		{
			ids += this.value + ',';
		}
	});
	if(ids == '')
	{
		alert('请至少选择一项');
		return false;
	}
	window.top.art.dialog(
	{
		title:'删除信息',
		content: '你确定要删除这些信息吗？<br />删除后无法恢复，若想恢复请取消此项操作，选择“禁用”',
		fixed:true,
		id:'delete_check'
	},
	function ()
	{
		$.ajax({
			type: "POST",
			url: "?m=admin&c=content_manage&a=delete",
			data: "id=" + ids,
			success: function(data){
				parent.main.location.reload();
			}
		});
	},
	function (){window.top.art.dialog({id:'delete_check'}).close();});
}
</script>